package 木棒;


import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N = 70, sum, len, n;
    static Integer[] w = new Integer[N];
    static boolean[] st = new boolean[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (true) {
            sum = len = 0;
            Arrays.fill(st, false);
            n = in.nextInt();
            if (n == 0) {
                break;
            }
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
                sum += w[i];
                len = Math.max(len, w[i]);
            }
            Arrays.sort(w, 0, n, (a, b) -> {
                return b - a;
            });
            while (true) {
                if (sum % len == 0 && dfs(0, 0, 0)) {
                    System.out.println(len);
                    break;
                }
                len++;
            }
        }
    }

    private static boolean dfs(int u, int l, int start) {
        if (u * len == sum) {
            return true;
        }
        if (l == len) {
            return dfs(u + 1, 0, 0);
        }
        for (int i = start; i < n; i++) {
            if (st[i]) {
                continue;
            }
            if (l + w[i] <= len) {
                st[i] = true;
                if (dfs(u, l + w[i], i + 1)) {
                    return true;
                }
                st[i] = false;
            }
            if (l == 0 || l + w[i] == len) {
                return false;
            }
            int j = i + 1;
            while (j < n && w[j] == w[i]) {
                j++;
            }
            i = j - 1;
        }
        return false;
    }
}
